package repositories;

import database.DAO;
import database.IDAO;
import webservice.Playlist;
import webservice.Track;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Wrflohil
 * Date: 13-6-13
 * Time: 9:39
 * To change this template use File | Settings | File Templates.
 */
public class PlaylistRepository implements IPlaylistRepository {
    private IDAO dao;

    public PlaylistRepository(IDAO dao) {
        this.dao = dao;
    }

    public PlaylistRepository() {
    }

    public Playlist getPlaylist(String username, String playlistname, List<Track> tracks) {
        Playlist playlist = new Playlist();
        playlist.setName(playlistname);
        for(Track track : tracks) {
            playlist.getTrack().add(track);
        }
        playlist.setUserName(username);
        dao.insertPlaylist(playlist);

        return playlist;
    }
}
